import numpy as np
from scipy.integrate import quad

# 连续函数示例：可积
def continuous_func(x):
    return np.sin(x) + np.cos(x)

# 单调函数示例：可积  
def monotonic_func(x):
    return x**3

# 有界但不可积函数示例
def dirichlet_approx(x):
    # 近似狄利克雷函数
    return np.where(np.abs(np.sin(x * np.pi)) < 1e-10, 1, 0)

# 测试可积性
functions = [
    ("连续函数", continuous_func),
    ("单调函数", monotonic_func),
    ("狄利克雷函数近似", dirichlet_approx)
]

for name, func in functions:
    try:
        result, error = quad(func, 0, 1, limit=100)
        print(f"{name}: 可积，积分值 = {result:.6f}")
    except Exception as e:
        print(f"{name}: 不可积，错误信息: {e}")